import java.util.*;

public class Main {

    public static List<Card> allcard = new ArrayList<>();

    static{
        String[] sizes = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        String[] colors = {"红桃","红方块","黑桃","黑梅"};
        for (String size : sizes) {
            for (String color : colors) {
                Card card = new Card(size,color);
                allcard.add(card);
            }
        }
        Card card1 = new Card("","小王");
        Card card2 = new Card("","大王");
        Collections.addAll(allcard,card1,card2);
        System.out.println("新牌"+allcard);
    }

    public static void main(String[] args) {
        //1.洗牌
        Collections.shuffle(allcard);
        System.out.println("洗牌后"+allcard);
        System.out.println();
        //2.构建玩家所持有的牌
        List<Card> p1 = new ArrayList<>();
        List<Card> p2 = new ArrayList<>();
        List<Card> p3 = new ArrayList<>();
        //3.发牌
        for (int i = 0; i < allcard.size()-3; i++) {
            if(i%3==0){
                p1.add(allcard.get(i));
            }else if(i%3==1){
                p2.add(allcard.get(i));
            }else{
                p3.add(allcard.get(i));
            }
        }
        //4.把最后三张牌组合成一个子集合
         List<Card>Lastthree = allcard.subList(allcard.size()-3,allcard.size());

        //5.给玩家的牌排序
        Collections.sort(p1);
        Collections.sort(p2);
        Collections.sort(p3);

        //6.输出玩家的牌
        System.out.println("p1"+p1);
        System.out.println("p2"+p2);
        System.out.println("p3"+p3);
        System.out.println("Lastthree"+Lastthree);
    }
}
